rethinking
brms
rstanarm
rstancmdstanrInconvenience in one context is convenience in another.
cmdstanrrstan
rethinking and brms can use as the backend samplerrethinkingrethinking::stancode())
brmsrstanarmstan_lm(), stan_glm(), stan_lmer(), stan_aov(), etc.brms?Provided a model and data, brms::get_prior() gives you the list of defaults:
Family: gaussian
Links: mu = identity; sigma = identity
Formula: y ~ x + 1
Data: D (Number of observations: 50)
Draws: 4 chains, each with iter = 5000; warmup = 2500; thin = 1;
total post-warmup draws = 10000
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept 4.89 0.60 3.71 6.08 1.00 8731 6637
x -1.93 0.11 -2.14 -1.72 1.00 8363 6502
Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma 2.18 0.23 1.80 2.69 1.00 8622 6986
Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
posteriorposterior extracts these in useful formatsdraws_df [10,000 × 8] (S3: draws_df/draws/tbl_df/tbl/data.frame)
$ b_Intercept: num [1:10000] 5.08 4.64 5.19 4.64 4.26 ...
$ b_x : num [1:10000] -1.94 -1.96 -1.94 -1.92 -1.87 ...
$ sigma : num [1:10000] 2.34 1.99 2.07 2.23 2.22 ...
$ lprior : num [1:10000] -8.33 -8.34 -8.32 -8.34 -8.35 ...
$ lp__ : num [1:10000] -116 -116 -116 -116 -116 ...
$ .chain : int [1:10000] 1 1 1 1 1 1 1 1 1 1 ...
$ .iteration : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
$ .draw : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
pars = to select variables for plottingdraws_df [10,000 × 6] (S3: draws_df/draws/tbl_df/tbl/data.frame)
$ b_Intercept: num [1:10000] 5.08 4.64 5.19 4.64 4.26 ...
$ b_x : num [1:10000] -1.94 -1.96 -1.94 -1.92 -1.87 ...
$ sigma : num [1:10000] 2.34 1.99 2.07 2.23 2.22 ...
$ .chain : int [1:10000] 1 1 1 1 1 1 1 1 1 1 ...
$ .iteration : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
$ .draw : int [1:10000] 1 2 3 4 5 6 7 8 9 10 ...
bayesplotbayesplot automates many common plotting goalsposteriormcmc_trace()mcmc_rank_overlay()mcmc_acf()mcmc_combo()mcmc_trace()mcmc_rank_overlay()mcmc_combo()sample_prior = "only" ignores the data and samples the prior only.data nonethelessdatapp_check(): access many different checks for brm() models from bayesplot
Density overlay of 50 draws from the prior (PP)
Median of \(y\) plotted over a histogram of prior predicted values for \(y\)
Density overlay of 50 draws from the posterior (fm)
Posterior predicted intervals and observed vs. \(x\)
“Residual” mean predicted error vs. \(x\)
mcmc_dens(), mcmc_dens_overlay(), mcmc_areas()mcmc_intervals()mcmc_dens()mcmc_dens_overlay()mcmc_areas()tidybayes: tidy data + ggplot